﻿Chenxin.UI.ShowListIntent = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/ShowListIntent.ashx',
    createSearch: function() {
        return new Chenxin.UI.ShowListIntentSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.ExpandGrid({
            actionUrl: this.actionUrl + '?op=search',
            id: 'Letter_table',
            renderTo: 'Letter_table',
            hasCheckBox: true,
            cellBorder: true,
            pageSize: 50,
            height: 400,
            scope: this,
            columns: {
                IntentionId: {
                    create: false,
                    head: 'id',
                    sortable: true
                },
                Status: {
                    head: '状态',
                    width: 50,
                    sortable: true,
                    renderer: function(val) {
                        var _v = '';
                        switch (val) {
                            case '遗失':
                                _v = '<span style="color:#ffff99">' + val + '</span>';
                                break;
                            case '未领用':
                                _v = '<span style="color:#ff9900">' + val + '</span>';
                                break;
                            case '生效':
                                _v = '<span style="color:#006600">' + val + '</span>';
                                break;
                            case '作废':
                                _v = '<span style="color:#0033ff">' + val + '</span>';
                                break;
                            case '未使用':
                                _v = '<span style="color:#">' + val + '</span>';
                                break;
                        }
                        return _v;
                    }
                },
                IntentionCode: {
                    head: '意向书编号',
                    width: 180,
                    sortable: true
                },
                BusinessType: {
                    head: '类型',
                    width: 70,
                    sortable: true
                },
                BelongCompany: {
                    head: '公司',
                    width: 70,
                    sortable: true
                },
                business: {
                    head: '商圈',
                    width: 100
                },
                BelongDepart: {
                    head: '门店',
                    width: 100,
                    sortable: true
                },
                BelongEmp: {
                    head: '门店秘书',
                    width: 70,
                    sortable: true
                },
                DeliverTime: {
                    head: '秘书领取时间',
                    width: 90,
                    sortable: true
                },
                LastEmployee: {
                    head: '业务员',
                    width: 70,
                    sortable: true
                },
                LastEmployeeGetTime: {
                    head: '业务员领取时间',
                    width: 90,
                    sortable: true
                },
                Region: {
                    head: '区域',
                    width: 70,
                    sortable: true
                },
                HouseAddress: {
                    head: '物件地址',
                    width: 150,
                    sortable: true
                },
                TotalPrice: {
                    head: '房屋价格',
                    width: 70,
                    sortable: true
                },
                CustomerName_Sale: {
                    head: '房东姓名',
                    width: 70,
                    sortable: true
                },
                CustomerName_Buy: {
                    head: '客户姓名',
                    width: 70,
                    sortable: true
                },
                FirstMoney: {
                    head: '首笔诚意金余额',
                    width: 70,
                    sortable: true
                },
                TotalMoney: {
                    head: '诚意金总额',
                    width: 70,
                    sortable: true
                },
                GetedMoney: {
                    head: '已收金额',
                    width: 70,
                    sortable: true
                },
                DeliveredMoney: {
                    head: '已转金额',
                    width: 70,
                    sortable: true
                },
                LastMoney: {
                    head: '剩余金额',
                    width: 70
                },
                bContracted: {
                    head: '是否成交',
                    width: 70,
                    sortable: true
                },
                ContractCode: {
                    head: '成交编号',
                    width: 150,
                    sortable: true
                },
                ChangeTime: {
                    head: '换领时间',
                    width: 70,
                    sortable: true
                }
            }
        });
    },
    loadinfo: function() {
        var _this = this;
        if (!this.currentId) {
            alert("请先选择一条记录！");
            return false;
        }
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async: false,
            url: this.actionUrl,
            data: { op: 'getmodel', modelid: this.currentId },
            onSuccess: function(data, msg) {
                if (data) {
                    _this.currentInfo = data;
                }
            }
        });
        return true;
    },
    initEvent: function() {
        var _this = this;
        /*************************事件：起始日期得到焦点************************/
        $("#DateFr").focus(function() {
            WdatePicker({ dateFmt: 'yyyy-MM-dd', oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        });
        /*************************事件：终止日期得到焦点************************/
        $("#DateTo").focus(function() {
            WdatePicker({ dateFmt: 'yyyy-MM-dd', oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        });
        /*************************事件：意向书编号发放************************/
        $("#aLetterIssue").click(function() {
            _this.LetterIssue();
        });
        /*************************事件：意向书编号下发************************/
        $("#aDeliver").click(function() {
            _this.deliverCode();
        });
        /*************************事件：意向书编号领用************************/
        $("#aGetLetter").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.GetLetter();
        });
        /*************************事件：意向书资料输入************************/
        $("#aInputInfo").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.Status != -100) {
                alert('只有"未使用"状态下，才能执行此操作！');
                return;
            }
            _this.showDataInput(_this.currentInfo.IntentionType == 10 ? true : false);
        });
        /*************************事件：意向书资料编辑************************/
        $("#aInfoEdit").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.Status != -10 && _this.currentInfo.Status != 10) {
                alert("状态为'未生效'或'生效'的记录才能执行该操作！");
                return;
            }
            _this.showDataEdit(_this.currentInfo.IntentionType == 10 ? true : false);
        });
        /*************************事件：意向书作废************************/
        $("#aDelete").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.changeStatusInfo(20);
        });
        /*************************事件：意向书生效************************/
        $("#aEffective").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.Status != -10) {
                alert('只有"未生效"状态下，执行此操作！');
                return;
            }
            _this.del('effective', '确定生效该意向书？');
        });
        /*************************事件：意向书无效************************/
        $("#aUseless").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.changeStatusInfo(10);
        });
        /*************************事件：意向书遗失************************/
        $("#aLost").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.changeStatusInfo(30, false);
        });
        /*************************事件：法务回收************************/
        $("#aRecallByFW").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.recall('recallbyfw');
        });

        /*************************事件：门店回收************************/
        $("#aRecallByMD").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.recall('recallbymd');
        });
        /*************************事件：业务员变更************************/
        $("#aChgEmp").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.Status != -100) {
                alert("状态为“未使用”的记录才能执行该操作！");
            } else {
                _this.ChgEmp();
            }
        });
        /*************************事件：查看详情************************/
        $("#aDetail").click(function() {
            if (_this.currentId == "") {
                alert("请选择一条记录！");
            }
            else {
                window.open("/page/LetterOfIntent_Mgr/IntentDetail.aspx?IntentionId=" + _this.currentId + "");
            }
        });
        /*************************事件：意向金开单************************/
        $("#aBill_get").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.TotalMoney == _this.currentInfo.GetedMoney) {
                alert("该意向书收款已收齐，不能执行意向金收款！");
            }
            else {
                _this.billing();
            }
        });
        /*************************事件：意向金转移************************/
        $("#aBill_pay").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            _this.currentInfo.GetedMoney = _this.currentInfo.GetedMoney || 0;
            if (_this.currentInfo.GetedMoney <= 0) {
                alert("该意向书无收款，无法进行转移！");
            }
            else if (_this.currentInfo.GetedMoney == _this.currentInfo.DeliveredMoney) {
                alert("该意向书转移金额达上限，无法进行转移！");
            }
            else {
                _this.paying();
            }
        });
        /*************************事件：增加意向金************************/
        $("#aAddMoney").click(function() {
            if (!_this.loadinfo()) {
                return;
            }
            if (_this.currentInfo.Status != -10 && _this.currentInfo.Status != 10) {
                alert("状态为'未生效'或'生效'的记录才能执行该操作！");
            }
            else {
                _this.AddMoney();
            }
        });
    },
    /**
    *意向书编号发放
    */
    LetterIssue: function() {
        var _this = this;
        if (!this.LetterCodeIssueForm) {
            this.LetterCodeIssueForm = new Chenxin.UI.LetterCodeIssueForm({
                scope: _this,
                alwaysCheckPermit: true,
                title: '意向书编号发放',
                op: 'issue',
                afterGetFormJson: function(json) {
                    delete json.areaid;
                    delete json.area;

                    if (json.BusinessType == '20') {
                        json.IntentionType = 0;
                    }
                    if (json.code_year_type == '20') {
                        this.LetterCodeIssueForm.additionalParam.code_year = json.code_year;
                    } else {
                        if (this.LetterCodeIssueForm.additionalParam.code_year) {
                            delete this.LetterCodeIssueForm.additionalParam.code_year;
                        }
                    }
                    delete json.code_year_type;
                    delete json.code_year;
                },
                saveSucc: function() {
                    _this.grid.reload();
                }
            });
        }
        if (this.LetterCodeIssueForm.show()) {
            this.LetterCodeIssueForm.reset();
        }
    },
    /**
    *意向书编号下发
    */
    deliverCode: function() {
        var _length = this.grid.getSelectLength();
        if (_length < 1) {
            alert('请选择至少一条记录');
            return;
        }
        if (_length > 10) {
            alert('选择记录不能超过10条');
            return;
        }
        var idList = this.grid.getSelectList();
        if (!this.deliverForm) {
            this.deliverForm = new Chenxin.UI.LetterCodeDeliverForm({
                title: '编号下发',
                scope: this,
                afterGetFormJson: function(json) {
                    Chenxin.apply(this.deliverForm.additionalParam, json);
                    var idlist = [];
                    for (var m in this.deliverForm.grid.store.map) {
                        idlist.push(m);
                    }
                    this.deliverForm.additionalParam.idlist = idlist.join(',');
                }
            });
        }
        if (this.deliverForm.show()) {
            this.deliverForm.reset();
            this.deliverForm.grid.reload({ idlist: idList });
        }
    },
    /**
    *意向书编号领用
    */
    GetLetter: function() {
        var _this = this;
        if (this.currentInfo.Status == -200) {
            var idList = this.grid.getSelectList();
            var strList = idList.split(',');
            if (strList[1] != undefined) {
                alert("请不要多选，领用只可单选！");
                _this.grid.reload();
                return;
            }
            if (!this.GetLetterForm) {
                this.GetLetterForm = new Chenxin.UI.GetLetterForm({
                    scope: this,
                    title: '意向书编号领用',
                    op: 'getletter',
                    afterGetFormJson: function(json) {
                    },
                    beforeFitData: function(model) {
                        this.GetLetterForm.findByName('BelongDepartId').vv = model.BelongDepartId;
                        this.GetLetterForm.findByName('LastEmployeeId').loadUser(model.BelongDepartId);
                    },
                    saveSucc: function() {
                        _this.grid.reload();
                    }
                });
            }
            if (this.GetLetterForm.show(this.GetLetterForm.op, { currentId: _this.currentId })) {
                this.GetLetterForm.fitData({
                    IntentionCode: this.currentInfo.IntentionCode,
                    IntentionId: this.currentInfo.IntentionId,
                    BelongDepartId: this.currentInfo.BelongDepartId
                });
            }
        }
        else {
            alert("此记录已领用！");
            return;
        }
    },
    /**
    *@description 资料输入
    *@isSale true买卖协议，false为居间合同
    */
    showDataInput: function(isSale) {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }
        if (!this.dataInput) {
            this.dataInput = new Chenxin.UI.DataInputForm({
                scope: this,
                op: 'inputinfo',
                beforeFitData: function(model) {
                    model.IntentionType = model.IntentionType == 10 ? '买卖协议' : '居间协议';
                    var region = this.dataInput.findByName('Region');
                    region.param.cityid = model.BelongCityId;
                    region.reload();
                },
                afterGetFormJson: function(model) {
                    delete model.IntentionType;
                },
                saveSucc: function() {
                    this.grid.reload();
                }
            });
        }

        if (this.dataInput.show()) {
            this.dataInput.fitData(this.currentInfo);
            $('#span_codelabel').html(isSale ? '买卖协议编号' : '居间合同编号');
            $('#tr_emoney')[isSale ? 'show' : 'hide']();
            this.dataInput.setTitle(isSale ? '买卖协议资料输入' : '居间合同资料输入');
        }
    },
    /**
    *@description 资料修改
    *@isSale true买卖协议，false为居间合同
    */
    showDataEdit: function(isSale) {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }
        if (!this.dataEdit) {
            this.dataEdit = new Chenxin.UI.DataEditForm({
                scope: this,
                op: 'editinfo',
                beforeFitData: function(model) {
                    model.IntentionType = model.IntentionType == 10 ? '买卖协议' : '居间协议';
                    var region = this.dataEdit.findByName('Region');
                    region.param.cityid = model.BelongCityId;
                    region.reload(model.Region);
                },
                afterGetFormJson: function(model) {
                    delete model.IntentionType;
                },
                saveSucc: function() {
                    this.grid.reload();
                }
            });
        }

        if (this.dataEdit.show()) {
            if (this.currentInfo.LastContractDate != null)
                this.currentInfo.LastContractDate = this.currentInfo.LastContractDate.split(" ")[0];
            if (this.currentInfo.LastDeliverMoneyDate != null)
                this.currentInfo.LastDeliverMoneyDate = this.currentInfo.LastDeliverMoneyDate.split(" ")[0];
            this.dataEdit.fitData(this.currentInfo);
            $('#span_codelabel').html(isSale ? '买卖协议编号' : '买卖居间编号');
            $('#tr_emoney')[isSale ? 'show' : 'hide']();
            this.dataEdit.setTitle(isSale ? '买卖协议编辑' : '买卖居间编辑');
        }
    },
    /**
    *@description 作废、无效、遗失操作
    *status 10为无效，20为作废，30为遗失
    */
    changeStatusInfo: function(status, check) {
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            this.grid.reload();
            return;
        }
        check = check == undefined ? true : false;
        if (check) {
            if (this.currentInfo.Status == -30 && status == 30) {
                alert("此记录已遗失，不可执行操作！");
                return;
            }
            if (this.currentInfo.Status != -10 && status == 20) {
                alert("只有'未生效'状态下，可执行作废操作！");
                return;
            }
            if (this.currentInfo.Status != 10 && status == 10) {
                alert("只有'生效'状态下，可执行作废操作！");
                return;
            }
        }

        if (!this.changeStatusForm) {
            this.changeStatusForm = new Chenxin.UI.ChangeStatusInfoForm({
                scope: this,
                afterGetFormJson: function(json) {
                    switch (this.changeStatusForm.status) {
                        case 10:
                            json.StatusDescription = json.uselessreason;
                            handlerChk(false);
                            break;
                        case 20:
                            json.StatusDescription = json.delreason;
                            handlerChk(false);
                            break;
                        case 30:
                            handlerChk(true);
                            break;
                    }
                    function handlerChk(autoAdd) {
                        json.StatusDescription = '';
                        for (var i = 1; i < 8; i++) {//StatusDescription
                            if (json['chk_reason_' + i]) {
                                if (autoAdd) {
                                    json.StatusDescription += json['chk_reason_' + i] + ',';
                                }
                                delete json['chk_reason_' + i];
                            }
                        }
                        json.LostItems = '';
                        for (var i = 1; i < 4; i++) {//LostItem
                            if (json['chk_page_' + i]) {
                                if (autoAdd) {
                                    json.LostItems += json['chk_page_' + i] + ',';
                                }
                                delete json['chk_page_' + i];
                            }
                        }
                    }
                    delete json.uselessreason; //删除radio的值
                    delete json.delreason; //删除textarea的值
                },
                saveSucc: function() {
                    this.grid.reload();
                }
            });
        }
        this.changeStatusForm.status = status;
        switch (status) {
            case 10:
                this.changeStatusForm.op = 'uesless';
                this.changeStatusForm.setTitle('意向书失效');
                $('.tr-houseowner').show();
                $('.tr-fail').show();
                $('.tr-invalid').hide();
                $('.tr-lost').hide();
                break;
            case 20:
                this.changeStatusForm.op = 'delete';
                this.changeStatusForm.setTitle('意向书作废');
                $('.tr-houseowner').show();
                $('.tr-fail').hide();
                $('.tr-invalid').show();
                $('.tr-lost').hide();
                break;
            case 30:
                this.changeStatusForm.op = 'lost';
                this.changeStatusForm.setTitle('意向书遗失');
                $('.tr-houseowner').hide();
                $('.tr-fail').hide();
                $('.tr-invalid').hide();
                $('.tr-lost').show();
                break;

        }
        if (this.changeStatusForm.show()) {
            this.changeStatusForm.fitData(this.currentInfo);
        }
    },

    /**
    *@description 门店回收，法务回收
    *@op recallbyfw为法务回收，recallbymd为门店回收
    */
    recall: function(type) {
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("请不要多选，回收只可单选！");
            this.grid.reload();
            return;
        }
        if (this.currentInfo.Status != -200 && this.currentInfo.Status != -100) {
            alert("此记录已领用或已使用不能回收！");
            return;
        }
        if (!confirm("是否回收该条记录！")) {
            return;
        }
        var op = type;
        var _this = this;
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async: false,
            url: this.actionUrl,
            data: { op: op, modelid: this.currentId },
            onSuccess: function(data, msg) {
                alert(msg);
                _this.grid.reload();
            }
        });
    },
    /**
    *业务员变更
    */
    ChgEmp: function() {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }
        if (!this.ChgEmpForm) {
            this.ChgEmpForm = new Chenxin.UI.ChgEmpForm({
                scope: _this,
                title: '业务员变更',
                afterGetFormJson: function(json) {
                    delete json.PrimaryEmployee;
                    delete json.PrimaryBelongEmp;
                },
                saveSucc: function() {
                    _this.grid.reload();
                }
            });
        }
        this.ChgEmpForm.op = "chgemp";
        if (this.ChgEmpForm.show(this.ChgEmpForm.op, { currentId: _this.currentId })) {
            var _data = {};
            Chenxin.apply(_data, this.currentInfo);
            _data.PrimaryEmployee = _data.LastEmployee;
            _data.PrimaryBelongEmp = _data.BelongEmp;
            _data.LastEmployee = null;
            _data.BelongEmp = null;
            _this.ChgEmpForm.fitData(_data);

        }
    },
    /**
    *增加意向金
    */
    AddMoney: function() {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }

        if (!this.AddMoneyForm) {
            this.AddMoneyForm = new Chenxin.UI.AddMoneyForm({
                scope: this,
                op: 'addmoney',
                title: '增加意向金',
                afterGetFormJson: function(json) {
                    delete json.IntentionCode;
                    delete json.LastEmployee;
                    delete json.CreateDate;
                    delete json.CreateEmp;
                    delete json.HouseAddress;
                    delete json.TotalMoney;
                    delete json.TotalPrice
                    delete json.CustomerName_Sale;
                    delete json.CustomerName_Buy;
                    delete json.FirstMoney;
                },
                saveSucc: function() {
                    _this.grid.reload();
                }
            });
        }
        if (this.AddMoneyForm.show(this.AddMoneyForm.op, { currentId: _this.currentId })) {
            this.AddMoneyForm.fitData(this.currentInfo);
        }
    },
    /**
    *开单
    */
    billing: function() {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }
        if (this.currentInfo.Status != 10) {
            alert('状态为“生效”方可执行此操作！');
            return false;
        }
        if (!this.billingForm) {
            this.billingForm = new Chenxin.UI.BillingForm({
                scope: this,
                title: '意向金收款',
                op: 'billadd',
                afterGetFormJson: function(json) {
                    var itemList = [];
                    for (var i = 0; i < this.billingForm.drCount; i++) {
                        if (json['PayMode_' + i] != undefined && json['PayMoney_' + i] != undefined) {
                            if ((json['PayMode_' + i] == 'POS机刷卡' || json['PayMode_' + i] == '支/本票') && (json['PayCode_' + i] == undefined || json['PayName_' + i] == undefined)) {

                            } else {
                                var t = {};
                                t['PayMode'] = json['PayMode_' + i];
                                t['PayName'] = json['PayName_' + i];
                                t['PayCode'] = json['PayCode_' + i];
                                t['PayMoney'] = json['PayMoney_' + i];
                                t['PayMemo'] = json['PayMemo_' + i] || '';
                                itemList.push(t);
                            }
                        }
                    }
                    /* if(parseFloat(json.GetedMoney) > parseFloat(json.TotalMoney)){
                    alert('开单金额必须小于或等于总诚意金额！');
                    return false;
                    }
                    if(parseFloat(json.GetedMoney) == "0"){
                    alert('开单金额必须大于0！');
                    return false;
                    }
                    if(parseFloat(json.IsGetedMoney) >= parseFloat(json.TotalMoney)){
                    alert('此次开单金额与已开单金额之和不能超过总额！');
                    return false;
                    }
                    else if(parseFloat(json.IsGetedMoney) + parseFloat(json.GetedMoney) > parseFloat(json.TotalMoney)){
                    alert('此次开单金额与已开单金额之和不能超过总额！');
                    return false;
                    } */
                    delete json.LastEmployee;
                    delete json.CustomerName_Sale;
                    delete json.CustomerName_Buy;
                    delete json.HouseAddress;
                    delete json.TotalPrice;

                    this.billingForm.additionalParam.lsBillItem = '[' + itemList.toString() + ']';
                },
                saveSucc: function(data) {
                    var _this = this;
                    _this.CurModel = data.model;
                    if (_this.printInForm == undefined) {
                        _this.printInForm = new Chenxin.UI.PrintInMoneyForm({
                            scope: _this,
                            op: 'printview'
                        });
                    }

                    if (_this.printInForm.show('reprintview') == false) return;
                    _this.printInForm.reset();
                    _this.printInForm.fitData(_this.CurModel);
                    _this.grid.reload();
                }
            });
        }
        if (this.billingForm.show()) {
            this.billingForm.reset();

            var _data = {};
            Chenxin.apply(_data, this.currentInfo);
            _data.GetedDepartId = _data.BelongDepartId;
            _data.GetedMoney = _data.GetedMoney || 0;
            _data.IsGetedMoney = _data.GetedMoney;
            _data.GetedMoney = _data.TotalMoney - _data.GetedMoney;
            _data.GetedDepartId = _data.BelongDepartId;
            this.billingForm.fitData(_data);
            // if(this.currentInfo.GetedMoney == "" || this.currentInfo.GetedMoney == null)
            // {
            // this.billingForm.findByName('IsGetedMoney').val(0);
            // this.billingForm.findByName('GetedMoney').val(this.currentInfo.TotalMoney);
            // }
            // else
            // {
            // this.billingForm.findByName('IsGetedMoney').val(this.currentInfo.GetedMoney);
            // this.billingForm.findByName('GetedMoney').val(parseFloat(this.currentInfo.TotalMoney) - parseFloat(this.currentInfo.GetedMoney));
            // }
        }
    },
    /**
    *转移
    */
    paying: function() {
        var _this = this;
        var idList = this.grid.getSelectList();
        var strList = idList.split(',');
        if (strList[1] != undefined) {
            alert("该操作只针对单条记录，请不要多选！");
            _this.grid.reload();
            return;
        }
        if (this.currentInfo.Status != 10) {
            alert('状态为“生效”方可执行此操作！');
            return false;
        }
        if (!this.payingForm) {
            this.payingForm = new Chenxin.UI.PayingForm({
                scope: this,
                title: '意向金转移',
                op: 'payadd',
                afterGetFormJson: function(json) {
                    this.payingForm.additionalParam.PayMoney = json.PayMoney;

                    delete json.LastEmployee;
                    delete json.CustomerName_Sale;
                    delete json.CustomerName_Buy;
                    delete json.HouseAddress;
                    delete json.TotalPrice;

                },
                saveSucc: function(data) {
                    var _this = this;
                    _this.CurModel = data.model;
                    if (_this.CurModel.PayTo == "退还客户") {
                        if (_this.printOutForm == undefined) {
                            _this.printOutForm = new Chenxin.UI.PrintOutToMoneyForm({
                                scope: _this,
                                op: 'printview'
                            });
                        }

                        if (_this.printOutForm.show('reprintview') == false) return;
                        _this.printOutForm.reset();
                        _this.printOutForm.fitData(_this.CurModel);
                    }
                    else {
                        if (_this.printMoveForm == undefined) {
                            _this.printMoveForm = new Chenxin.UI.PrintOutMoveMoneyForm({
                                scope: _this,
                                op: 'printview'
                            });
                        }

                        if (_this.printMoveForm.show('reprintview') == false) return;
                        _this.printMoveForm.reset();
                        _this.printMoveForm.fitData(_this.CurModel);
                    }
                    _this.grid.reload();
                }
            });
        }
        if (this.payingForm.show()) {
            this.payingForm.reset();

            var _data = {};
            Chenxin.apply(_data, this.currentInfo);
            _data.GetedDepartId = _data.BelongDepartId;
            _data.PayMoney = _data.GetedMoney - _data.DeliveredMoney;
            this.payingForm.fitData(_data);
        }
    },
    initComponent: function() {
        Chenxin.UI.ShowListIntent.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.ShowListIntentSearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
    id:'Letter_search',
    initEvent:function(){
        var _this=this; 

        //查询按钮
        $('#btIntention_Search').click(function(){
              _this.scope.reloadGrid("",0);
        });
		
		
        $('#IntentionCode').defText({
            deftxt: '输入意向书编号...'
        });
        
        $('#DateFr').defText({
        deftxt: '请选择下发时间'
        });
        $('#DateTo').defText({
        deftxt: '请选择下发时间'
        });
    },
    createComboList: function(){
        //日期查询类型
        var ComboStatus = new Chenxin.UI.Combo({
            containerId: '#Status',
            tbxWidth: 65,
            colWidth: 80,
            items: comboCommon.IntentStatus
        });
        
        //五级联Combo
        var combl = new Chenxin.UI.StructComboList({			
            tbxWidth: 65
		});
        var structs = combl.comboList;
        structs.push(ComboStatus);
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.ShowListIntentSearch.superclass.initComponent.call(this);
    }
});
getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function(){
    var showlistintent = new Chenxin.UI.ShowListIntent();
});